import axios from 'axios';
import NProress from 'nprogress'; // 展示进度条的js库
import 'nprogress/nprogress.css';


const mockAxios = axios.create({
  baseURL: 'http://www.1010.com',
  timeout: 5000,
});

// 请求拦截器
mockAxios.interceptors.request.use((config) => {
  NProress.start(); // 启用进度条
  return config;
});

//  响应拦截器
mockAxios.interceptors.response.use(
  (response) => {
    NProress.done();
    return response.data;
  },
  (error) => {
    NProress.done();
    return Promise.reject(error);
  }
);

export default mockAxios;
